<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="menu" content="assetMenu" />
<meta name="nav" content="1" />
<meta name="acc" content="0" />
<title>收文登记</title>
<%@ include file="/common/extjs.jsp"%>
<script type="text/javascript"
	src="<c:url value='/ext/ux/FieldLabeler.js'/>" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8" src="<c:url value='/KindEditor/kindeditor.js'/>"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$("#type").focus();
		$("#received").validate({
				rules : {
					type : "required",
					staffs : "required",
					refeNum : {
						required : true,
						maxlength : 50,
						remote : "received_art!checkRefeNum.action?oldRefeNum="
							+ encodeURIComponent('${refeNum}')
					},
					officeNum : {
						required : true,
						maxlength : 50
					},
					secret : "required",
					crash : "required"
				},
				messages : {
					refeNum : {
						remote : "<font color='red'>发文字号已存在</font>"
					}
				}
		});
	});

	function changeDepName() {
		var url = "<c:url value='/account/api/department.action'/>";
		var obj = new Object();
		mm = window
				.showModalDialog(
						url,
						obj,
						'dialogHeight:500px;dialogWidth:780px;status:no;toolbar:no;resizable:no;menubar:no;location:no;scrollbars:no;dialogLeft:'
								+ (screen.width / 2.0 - 150) + ',dialogTop:170')
		if (mm != null) {
			$("input[name='department.id']").val(mm.id);
			$("input[name='department.depName']").val(mm.depName);
		}
	}

	function checkUser() {
		var url = "<c:url value='/account/json/userchooses.action'/>";
		var obj = new Object();
		mm = window
				.showModalDialog(
						url,
						obj,
						'dialogHeight:400px;dialogWidth:600px;status:no;toolbar:no;resizable:no;menubar:no;location:no;scrollbars:no;dialogLeft:'
								+ (screen.width / 2.0 - 150) + ',dialogTop:170')
		if (mm != null) {
			$("input[name='staffs']").val(mm);
		}
	}
	
	KE.show({
		id : 'content',
		cssPath : './index.css',
		afterCreate : function(id) {
			KE.event.ctrl(document, 13, function() {
				KE.sync(id);
				document.forms['received'].submit();
			});
			KE.event.ctrl(KE.g[id].iframeDoc, 13, function() {
				KE.sync(id);
				document.forms['received'].submit();
			});
		}
	});
</script>
</head>
<body>
	<h2>
		<s:if test="id == null">创建</s:if>
		<s:else>修改</s:else>
		收文
	</h2>
	<form id="received" action="received_art!save.action" method="post"
		class="yform">
		<input type="hidden" name="id" value="${id }" />
		<input type="hidden" name="taskId" value="${taskId }" />
		<input type="hidden" name="deploymentId" value="${deploymentId }" />
		<table class="noborder">
			<tr class="type-text">
				<td>来文分类&nbsp;<font color="red">*</font>:</td>
				<td ><input type="text" id="type" name="type"
					value="${type }" /></td>
			</tr>
			<tr class="type-text">
				<td>拟办人员&nbsp;<font color="red">*</font>:</td>
				<td ><input type="text" name="staffs" id="staffs" value="${staffs }"><input type="button" id="check"
					name="check" value="选择拟办人员" onclick="checkUser()"></td>
			</tr>
			<tr class="type-text">
				<td>发文字号&nbsp;<font color="red">*</font>:</td>
				<td><input type="text" id="refeNum" name="refeNum"
					value="${refeNum }" />
				</td>
			</tr>
			<tr class="type-text">
				<td>公文自编号&nbsp;<font color="red">*</font>:</td>
				<td><input type="text" id="officeNum" name="officeNum"
					value="${officeNum }" />
				</td>
			</tr>
			<tr class="type-text">
				<td>密集程度&nbsp;<font color="red">*</font>:</td>
				<td><input type="text" id="secret" name="secret"
					value="${secret }" />
				</td>
			</tr>
			<tr class="type-text">
				<td>紧急程度&nbsp;<font color="red">*</font>:</td>
				<td><input type="text" id="crash" name="crash"
					value="${crash }" />
				</td>
			</tr>

			<tr class="type-text">
				<td>发文机关或部门:</td>
				<td ><input type="hidden" name="department.id"
					value="${department.id}" /> <input type="text"
					name="department.depName" value="${department.depName }" />
					<div class="type-button">
						<input type="button" onclick="changeDepName()">
					</div>
				</td>
			</tr>
			<tr class="type-text">
				<td>文件标题</td>
				<td ><input type="text" id="title" name="title"
					value="${title }" />
				</td>
			</tr>
			<tr class="type-text">
				<td>主题词</td>
				<td ><input type="text" id="keywords"
					name="keywords" value="${keywords }" />
				</td>
			</tr>
			<tr class="type-text">
				<td>公文来源</td>
				<td ><input type="text" id="source" name="source"
					value="${source }" />
				</td>
			</tr>
			<tr class="type-text">
				<td>内容简介</td>
				<td ><textarea cols="112" rows="3" id="content"
						name="content">${content }</textarea>
				</td>
			</tr>
			<tr class="type-text">
				<td>备注</td>
				<td ><textarea cols="112" rows="3" id="remark"
						name="remark">${remark }</textarea>
				</td>
			</tr>
			<tr>
				<td>附件</td>
				<td ><input type="file" id="annex" name="annex"
					value="${annex }" />
				</td>
			</tr>
			<tr>
				<td colspan="4">
					<div class="type-button">
						<security:authorize ifAnyGranted="ROLE_修改用户">
							<input   type="submit" class="submit" value="保存" />&nbsp;
					</security:authorize>
						<input   type="button" value="返回" class="reset"
							onclick="history.back()" />
					</div>
				</td>
			</tr>
		</table>
	</form>

</body>
</html>